const app = getApp()
var page = 1;
Page({
  goto: app.goto,
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    status: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    page = 1;
    app.api.client_parkingFee_getRechargeRecordByCommunity({
      token: wx.getStorageSync("token"),
      idCommunity: wx.getStorageSync("idCommunity"),
      page: page,
      rows: 10,
    }, (res) => {

      for (let i in res.data) {
        res.data[i].rechargeTime = res.data[i].rechargeTime.substring(0, 10);
        res.data[i].validTime = res.data[i].validTime.substring(0, 10);
      }

      this.setData({
        list: res.data,
        status: res.status
      })
      page++
    })




  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  goto_car_pay: function (e) {
    wx.navigateTo({
      url: '../car_pay/car_pay?type=1'
        + "&item=" + JSON.stringify(this.data.item)
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

    page = 1;
    app.api.client_parkingFee_getRechargeRecordByCommunity({
      token: wx.getStorageSync("token"),
      idCommunity: wx.getStorageSync("idCommunity"),
      page: page,
      rows: 10,
    }, (res) => {

      for (let i in res.data) {
        res.data[i].rechargeTime = res.data[i].rechargeTime.substring(0, 10);
        res.data[i].validTime = res.data[i].validTime.substring(0, 10);
      }

      this.setData({
        list: res.data
      })
      page++
      wx.stopPullDownRefresh();
    })


  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

    app.api.client_parkingFee_getRechargeRecordByCommunity({
      token: wx.getStorageSync("token"),
      idCommunity: wx.getStorageSync("idCommunity"),
      page: page,
      rows: 10,
    }, (res) => {

      for (let i in res.data) {
        res.data[i].rechargeTime = res.data[i].rechargeTime.substring(0, 10);
        res.data[i].validTime = res.data[i].validTime.substring(0, 10);
      }

      this.setData({
        list: this.data.list.concat(res.data)
      })
      page++
    })

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

})